import request from '@/utils/request'

// ==================== 学生端接口 ====================

// 查询我的志愿列表
export function listMyApplications() {
  return request({
    url: '/system/application/my/list',
    method: 'get'
  })
}

// 申请志愿
export function applyForTopic(data) {
  return request({
    url: '/system/application/apply',
    method: 'post',
    data: data
  })
}

// 取消志愿申请
export function cancelApplication(applicationId) {
  return request({
    url: '/system/application/cancel/' + applicationId,
    method: 'put'
  })
}

// 检查是否可以申请指定优先级
export function checkCanApply(priority) {
  return request({
    url: '/system/application/check/canApply/' + priority,
    method: 'get'
  })
}

// 查询我的志愿统计
export function getMyStats() {
  return request({
    url: '/system/application/my/stats',
    method: 'get'
  })
}

// ==================== 教师端接口 ====================

// 查询教师的申请列表（分页）
export function listTeacherApplications(query) {
  return request({
    url: '/system/application/teacher/list',
    method: 'get',
    params: query
  })
}

// 查询指定题目的申请列表
export function listApplicationsByTopic(topicId) {
  return request({
    url: '/system/application/teacher/topic/' + topicId,
    method: 'get'
  })
}

// 查询申请详情
export function getApplicationDetail(applicationId) {
  return request({
    url: '/system/application/teacher/detail/' + applicationId,
    method: 'get'
  })
}

// 录取学生
export function acceptStudent(applicationId) {
  return request({
    url: '/system/application/teacher/accept/' + applicationId,
    method: 'put'
  })
}

// 拒绝学生
export function rejectStudent(applicationId, data) {
  return request({
    url: '/system/application/teacher/reject/' + applicationId,
    method: 'put',
    data: data
  })
}

// 查询已录取的学生名单
export function listAcceptedStudents(query) {
  return request({
    url: '/system/application/teacher/accepted',
    method: 'get',
    params: query
  })
}

// 导出已录取学生名单
export function exportAcceptedStudents() {
  return request({
    url: '/system/application/teacher/export',
    method: 'post',
    responseType: 'blob'
  })
}

// ==================== 管理员端接口 ====================

// 查询所有申请列表
export function listApplication(query) {
  return request({
    url: '/system/application/list',
    method: 'get',
    params: query
  })
}

// 查询申请详情
export function getApplication(applicationId) {
  return request({
    url: '/system/application/' + applicationId,
    method: 'get'
  })
}

// 删除申请
export function delApplication(applicationId) {
  return request({
    url: '/system/application/' + applicationId,
    method: 'delete'
  })
}

// 导出申请列表
export function exportApplication(query) {
  return request({
    url: '/system/application/export',
    method: 'post',
    params: query,
    responseType: 'blob'
  })
}